package com.adtec.base.cloud.wechatservice.wechatcloud.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenAPIConfig {

//  @Bean
//  public GroupedOpenApi hospitalWeChatApi() {
//    return GroupedOpenApi.builder()
//            .group("01-企业微信")
//            .pathsToMatch("/hospitalWeChat/**")
//            .build();
//  }

    @Bean
    public GroupedOpenApi wechatEnterpriseApi() {
        return GroupedOpenApi.builder()
                .group("01-企业微信企业信息相关接口")
                .pathsToMatch("/wechatEnterprise/**")
                .build();
    }

    @Bean
    public GroupedOpenApi wechatAppApi() {
        return GroupedOpenApi.builder()
                .group("02-企业微信应用相关接口")
                .pathsToMatch("/wechatApp/**")
                .build();
    }

    @Bean
    public GroupedOpenApi wechatSendmessageApi() {
        return GroupedOpenApi.builder()
                .group("03-企业微信发送消息相关接口")
                .pathsToMatch("/wechatSendmessage/**")
                .build();
    }

    @Bean
    public GroupedOpenApi wechatUrlApi() {
        return GroupedOpenApi.builder()
                .group("03-企业微信交互sdkurl相关接口")
                .pathsToMatch("/wechatUrl/**")
                .build();
    }


    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .components(new Components()
                        .addSecuritySchemes("loginHeader", new SecurityScheme()
                                .type(SecurityScheme.Type.APIKEY)
                                .in(SecurityScheme.In.HEADER)
                                .name("userId")))
                .addSecurityItem(new SecurityRequirement().addList("loginHeader"));
    }
}
